package com.undsf.comikami

import okhttp3.OkHttpClient

/**
 * Created by Arathi on 2017/9/13.
 */
class DownloadTask {
    public static final int TASK_TYPE_NONE = 0
    public static final int TASK_TYPE_CREATE_DIRECTORY = 1
    public static final int TASK_TYPE_DOWNLOAD_FILE = 2

    public static final int TASK_STATUS_READY = 0
    public static final int TASK_STATUS_DOWNLOADING = 1
    public static final int TASK_STATUS_FAILURE = 2
    public static final int TASK_STATUS_SUCCESS = 3

    int type
    int status
    String url
    String directory
    String filename
    List<DownloadTask> children

    def execute() {
        if (type == TASK_TYPE_CREATE_DIRECTORY) {
            File dir = new File(directory)
            dir.mkdirs()
        }
        else if (type == TASK_TYPE_DOWNLOAD_FILE) {

        }

        if (children != null) {
            for (def task : children) {
                task.execute()
            }
        }
    }
}
